home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / chasm.arc / DIFFER.DOC < prev    next >
Encoding:
Text File  |  1983-07-20  |  8.6 KB  |  331 lines

  1.  
  2.                                                                     A-1
  3.  
  4.       Appendix A: Differences Between CHASM and That Other Assembler
  5.  
  6.       Virtually all magazine articles about assembly language
  7.       programming on the IBM PC assume that the reader is using That
  8.       Other Assembler - you know, the one that costs $100.  This
  9.       appendix will try to summarize the differences between the two
  10.       programs.  Please note that I do not own a copy of That Other
  11.       Assembler, and therefore this section is not complete, nor even
  12.       guaranteed to be correct.  Anyone with more experience is
  13.       invited to make additions or corrections.
  14.  
  15.       A. General Differences
  16.  
  17.       The biggest difference is philosophical.  The IBM assembler was
  18.       designed for use by professional assembly language programmers,
  19.       to write operating systems and other huge projects.  This is
  20.       reflected in the large size and relative complexity of the macro
  21.       assembler.
  22.  
  23.       On the other hand, CHASM was designed for use by beginners, to
  24.       write relatively short programs.  This was done by leaving out a
  25.       lot of the power offered by IBM's assembler, in exchange for
  26.       simplicity and small size.  The main simplification involved
  27.       producing object code in the COM format, rather than the EXE
  28.       format chosen by IBM. There are two main consequences of this
  29.       choice:
  30.  
  31.          1. You can't link routines assembled by CHASM to
  32.             compiled programs. (Although you *can* include them in
  33.             BASIC programs, interpreted or compiled.)
  34.  
  35.          2. Your program has to fit in one 64K segment.  If (shudder!)
  36.             you want to write a 256K assembly language program, you're
  37.             out of luck.
  38.  
  39.       Like Pascal, the IBM assembler is a strongly typed language.  By
  40.       requiring you to specify the *type* of each memory location you
  41.       will access in your program, the IBM assembler always knows what
  42.       size of memory operand you want.  The disadvantage is a loss of
  43.       freedom:  if you want to access only one byte of an area declared
  44.       as word, that's tough. 
  45.  
  46.       In analogy to the C language, CHASM is *not* strongly typed.
  47.       CHASM is perfectly happy extracting a byte from where you
  48.       originally set aside a word - CHASM can't tell the difference.
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                                                                     A-2
  69.  
  70.       The consequence of this is that you have to *tell* CHASM
  71.       explicitly whether you want a byte or a word every time you
  72.       access memory.  For any access to memory which doesn't have a
  73.       register as the other operand, you must add either a 'B' or a 'W'
  74.       to the instruction mnemonic used by IBM.
  75.  
  76.       B. Miscellaneous Differences:
  77.  
  78.          1. Short Jumps:
  79.  
  80.             IBM uses the SHORT keyword, CHASM uses an 'S' suffix.
  81.             Example:
  82.  
  83.             JMP   SHORT label    ;ibm
  84.             JMPS  label          ;chasm
  85.  
  86.          2. Offset Function:
  87.  
  88.             Where IBM precedes an operand with the keyword OFFSET,
  89.             CHASM has a *function* called OFFSET. CHASM requires
  90.             parentheses around the operand. Example:
  91.  
  92.             MOV   AX, OFFSET FCB  ;ibm
  93.             MOV   AX, OFFSET(FCB) ;chasm
  94.  
  95.          3. Declaring Storage:
  96.  
  97.             A.  If you don't care what value a memory location is
  98.                 initialized to, the IBM assembler allows you to specify
  99.                 '?' as its contents.  CHASM figures out how many bytes
  100.                 you are declaring by how many values you give, so you
  101.                 have to specify a starting value for every memory
  102.                 location you declare.  Example:
  103.  
  104.                 DB   ?      ;ibm
  105.                 DB   0      ;chasm
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                                                                     A-3
  135.  
  136.             B.  The IBM assembler has a dizzying array of storage
  137.                 defining pseudo-ops, in keeping with its strongly typed
  138.                 philosophy. In practice, the only ones you'll likely
  139.                 see are DB (declare byte) and DW (declare word).  Where
  140.                 you see DB in IBM syntax, declare a single byte in
  141.                 CHASM.  For DW, declare two bytes. Example:
  142.  
  143.                 DW     ?         ;ibm
  144.                 DB     00H, 00H  ;chasm
  145.  
  146.             C.  The IBM assembler allows the keyword DUP as an operand
  147.                 in storage declaring pseudo-ops.  This means to repeat
  148.                 the definition as many times as the number just before
  149.                 the DUP.  Example:
  150.  
  151.                 DW   3 DUP(?)  ;ibm
  152.                 DB   0, 0      ;chasm
  153.                 DB   0, 0      ;  "
  154.                 DB   0, 0      ;  "
  155.  
  156.       4. Expressions:
  157.  
  158.          The IBM assembler allows you to perform arithmetic within the
  159.          operand list to calculate an address or immediate operand.
  160.          Thus, if you wanted the offset of the third byte after a
  161.          label, you could use "label + 3" as an operand.  CHASM doesn't
  162.          support expression evaluation.  The solution is to add labels
  163.          to any locations accessed via an expression, then use the
  164.          label directly.  Example:
  165.  
  166.                   MOV AX, BUFFER + 3   ;ibm
  167.          BUFFER   DB  4 DUP(?)         ; "
  168.  
  169.                   MOV AX, BUFFER3      ;chasm
  170.          BUFFER   DB  0, 0, 0          ;  "
  171.          BUFFER3  DB  0                ;  "
  172.  
  173.          Sometimes a constant is given as an expression just to
  174.          emphasize its origin.  For any such expressions which do not
  175.          involve a label, just substitute the numerical value of the
  176.          expression.
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.                                                                     A-4
  201.  
  202.        5. Segment Overrides:
  203.  
  204.          The IBM assembler specifies a segment override as a prefix
  205.          attached to a memory operand.  CHASM uses a separate
  206.          instruction, SEG, to override the default segment register for
  207.          the following instruction.  Example:
  208.  
  209.          XOR  AL, ES:[DI]   ;ibm
  210.  
  211.          SEG  ES            ;chasm
  212.          XOR  AL, [DI]      ;  "
  213.  
  214.       6. ASSUME Pseudo-op:
  215.  
  216.          IBM's ASSUME pseudo-op tells the assembler where the segment
  217.          registers will be pointing.  CHASM always assumes that the CS,
  218.          DS and SS registers point to the beginning of the code
  219.          segment, and that the SS register has been set up to point to
  220.          a valid stack area.  If you find an ASSUME pseudo-op where the
  221.          CS, DS and ES registers point to different locations, you will
  222.          have to figure out the addresses for memory references in the
  223.          DS or ES segments yourself.
  224.  
  225.  
  226.       7. Segment Pseudo-op:
  227.  
  228.          This pseudo-op is used to set up multiple segments in the IBM
  229.          assembler.  Since CHASM only allows one segment, there is no
  230.          equivalent pseudo-op.  If there is only one segment definition
  231.          in an IBM assembler program, everything is fine, just leave
  232.          the pseudo-op out for CHASM.
  233.  
  234.          Often times the SEGMENT pseudo-op is used to provide
  235.          addressing of an area in the BIOS, or perhaps the interrupt
  236.          vector table at the beginning of memory.  For example, if a
  237.          program needed to get at the BIOS data area, in the IBM
  238.          assembler you would define a dummy segment with the same
  239.          structure as that in the BIOS listing in Technical Reference:
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.                                                                     A-5
  267.  
  268.            DATA          SEGMENT AT 40H
  269.            RS232_BASE    DW    4 DUP(?)
  270.            PRINTER_BASE  DW    4 DUP(?)
  271.            EQUIP_FLAG    DW    ?
  272.            MFG_TST       DB    ?
  273.            MEMORY_SIZE   DW    ?
  274.            IO_RAM_SIZE   DW    ?
  275.  
  276.          All this is really accomplishing is giving a name to some
  277.          memory locations which are outside the actual program being
  278.          written.
  279.  
  280.          For CHASM, you'll have to figure out the actual addresses of
  281.          any of these data areas you want to use.  In this case, you
  282.          can just look at the LOC column of the BIOS listing to get the
  283.          offset of each data area.  For example, EQUIP_FLAG is at
  284.          offset 10H (check page A-2 of Tech. Ref).  Given the
  285.          addresses, you can give CHASM names for each of the locations,
  286.          using the memory option of the EQU pseudo-op:
  287.  
  288.             RS232_BASE   EQU [00H]
  289.             PRINTER_BASE EQU [08H]
  290.             EQUIP_FLAG   EQU [10H]
  291.             MFG_TEST     EQU [12H]
  292.             MEMORY_SIZE  EQU [13H]
  293.             IO_RAM_SIZE  EQU [15H]
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.